<?php
if(isset($_SESSION['whichS']) and $_SESSION['whichS'] == 'view')
{	
	if(isset($_SESSION['view_type']) and $_SESSION['view_type'] == 'by_term')
	{

	}
	else if(isset($_SESSION['view_type']) and $_SESSION['view_type'] == 'all')
	{
		// prepare pages
		$num_of_rows = 5;
		$offset = 0;
		if(isset($_GET['index']))
		$offset = $_GET['index'] * $num_of_rows;

		/// pages operation
		$student_id = $_SESSION['student_id'];
		$sql = "SELECT COUNT(*) FROM diem WHERE mssv = '$student_id'";
		$result = mysqli_query($link, $sql);
		if(!$result)
		{
			$error = 'Error fetching count of scores';
			include '/includes/error.html.php';
			exit();
		}
		$row = mysqli_fetch_array($result);
		$count = $row[0];
		$pages = ceil($count / $num_of_rows);

		$_SESSION['pages'] = $pages;
	}
}

if(isset($_SESSION['whichS']) and $_SESSION['whichS'] == 'change')
{
	// nothing here now
}
?>